package system

import (
	"project-info/src/handle/system"
	"project-info/src/router/req"
	"project-info/src/router/variable"

	"github.com/gin-gonic/gin"
)

func init() {
	variable.InitRouteFunc = append(variable.InitRouteFunc, InitSystemRoutes)
}
func InitSystemRoutes(e *gin.Engine) {
	userGroup := e.Group("/user")
	reqs := []*req.Conf{
		req.NewPost("/auth/callback", system.HandleCallback),
		req.NewPost("/auth/refresh", system.RefreshToken),
		req.NewPost("/login", system.Login),
		req.NewGet("/loginOut", system.LoginOut).NeedToken(),
		req.NewGet("/getUserInfo", system.GetUserInfo).NeedToken(),
		req.NewPost("/page", system.PageUser).NeedToken(),
		req.NewPost("/add", system.AddUser).NeedToken(),
		req.NewDelete("/delete", system.DeleteUser).NeedToken(),
		req.NewPost("/getEmployeeList", system.GetEmployeeList).NeedToken(),
		req.NewGet("/roleIds", system.GetUserRoleIds).NeedToken(),
		req.NewGet("/options", system.GetUserOptions).NeedToken(),
	}
	req.BatchSetUpRouter(userGroup, reqs)

	menuGroup := req.NewGroup("/menu").NeedToken().SetUpGroup(e)
	reqs = []*req.Conf{
		req.NewGet("/get", system.GetMenu), //测试用的，写死数据
		req.NewGet("/list", system.GetMenuList),
		req.NewPost("/add", system.AddMenu),
		req.NewGet("/tree", system.TreeMenu),
		req.NewDelete("/delete", system.DeleteMenu),
	}
	req.BatchSetUpRouter(menuGroup, reqs)

	roleGroup := req.NewGroup("/role").NeedToken().SetUpGroup(e)
	reqs = []*req.Conf{
		req.NewPost("/page", system.PageRole),
		req.NewPost("/add", system.AddOrUpdateRole),
		req.NewDelete("/delete", system.DeleteRole),
		req.NewGet("/list", system.ListRole),
		req.NewPost("/getRoleList", system.GetRoleList),
		req.NewGet("/options", system.GetRoleOptions),
	}
	req.BatchSetUpRouter(roleGroup, reqs)

	departmentGroup := req.NewGroup("/department").NeedToken().SetUpGroup(e)
	reqs = []*req.Conf{
		req.NewPost("/getDepartmentList", system.GetDepartmentsList),
	}
	req.BatchSetUpRouter(departmentGroup, reqs)
}
